<?php
function  centerReplace($goalString,$startString,$endString,$replaceContent)
{


$initString=$goalString;
$start=$startString;
$end=$endString;
$front=strpos($initString,$start);//开始位置
$back=strpos($initString,$end);//结束位置
//echo $front."\n";
//echo $back."\n";
//echo $tihuan;
//exit;
 if (($front!==false) && ($back!==false)){//找到
 	$str=substr($initString,0,$front-1).$replaceContent.substr($initString,$back+strlen($end));

 	return $str;
 	
 }else{

	echo "sorry  replace failed\n";

	return  -1;
 }


}


$String="abcdefghijklmnopqrstuvwxiz";
$result=centerReplace($String,"kl","s","hello world");
echo $result;








?>